<?php
namespace modules\admin\action\show\admins;

use library\PageAction;
use idea\ap\Ap;
use helper\ErrorNo;
use helper\Util;

/**
 * EditAction class file
 * 更新管理员
 * @author 宋欢 <iphper@yeah.net>
 * @version $Id: EditAction.php 1 2013-02-08 00:48:06Z huan.song $
 * @package modules.admin.action.show.admins
 * @since 1.0
 */
class EditAction extends PageAction
{
	/**
	 * (non-PHPdoc)
	 * @see idea\mvc\interfaces.Action::run()
	 */
	public function run()
	{
		$request = Ap::getRequest();
		$ret = array();
		
		$id = $request->getInteger('id');
		$do = $request->getParam('do');
		if ($do === 'post') {
			$ret = Util::getService('Admins', 'admin')->edit($id, $request->getPost());
			if ($ret['err_no'] === ErrorNo::SUCCESS_NUM) {
				Util::refresh($ret);
			}
		}
		
		$data = Util::getService('Admins', 'admin')->findNoPwdByPk($id);
		$ret['data'] = $data['data'];
		$this->render($ret);
	}
}
